package cn.birdbaby.plugins.annotator.fieldannotator.fielddesc;

import cn.birdbaby.plugins.annotator.Context;
import cn.birdbaby.plugins.annotator.fieldannotator.FieldAnnotator;
import com.intellij.psi.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author llorando 8/8/24 2:55 pm
 * 添加fieldDesc注解
 */
public class FieldDescAnnotator extends FieldAnnotator {

    @Override
    public String getSimpleName() {
        return "FieldDesc";
    }

    @Override
    public String getFullName() {
        return "cn.birdbaby.common.annotation.FieldDesc";
    }

    @Override
    public Map<String, PsiAnnotationMemberValue> buildAnnotationContent(Context context) {
        Map<String, PsiAnnotationMemberValue> valueMap = new HashMap<>();
        // 默认设置英文名称
        PsiAnnotationMemberValue pkgNameValue = JavaPsiFacade.getElementFactory(context.getProject()).createExpressionFromText("\"" + translate((PsiField) context.getCurrentElement()) + "\"", context.getCurrentElement());
        valueMap.put("name", pkgNameValue);
        return valueMap;
    }

}
